package com.ssy.jt808.gateway.infrastructure.constant;

import com.ssy.gaea.redis.IRedissonSpringCacheConfig;
import org.redisson.spring.cache.CacheConfig;

/**
 * @author wangzezhou
 */
public enum TerminalMessageCache implements IRedissonSpringCacheConfig{

  /** 终端缓存 */
  TERMINAL_TOKEN(48*3600);

  TerminalMessageCache( int ttl ){
    this(ttl, ttl, 0);
  }

  TerminalMessageCache( int ttl, int maxSize ){
    this(ttl, ttl, maxSize);
  }

  TerminalMessageCache( int ttl, int maxIdleTime, int maxSize ){
    this.ttl = ttl*1000;
    this.maxIdleTime = maxIdleTime*1000;
    this.maxSize = maxSize;
  }

  private int ttl;
  private int maxIdleTime;
  private int maxSize;

  /**
   * 缓存过期时间（单位毫秒），详见 {@link CacheConfig.ttl}
   *
   * @return 缓存过期时间
   */
  @Override
  public int ttl(){
    return this.ttl;
  }

  /**
   * 缓存最大空闲时间（单位毫秒）,详见 {@link CacheConfig.maxIdleTime}
   *
   * @return
   */
  @Override
  public long maxIdleTime(){
    return this.maxIdleTime;
  }

  /**
   * 缓存元素最大数，详见 {@link CacheConfig.maxSize}
   *
   * @return 缓存元素最大数
   */
  @Override
  public int maxSize(){
    return this.maxSize;
  }
}
